package org.xyl.config;

import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

/**
 * DashScope配置类，用于管理通义千问API的配置信息
 */
@Configuration
public class DashScopeConfig {

    @Value("${dashscope.api-key:}")
    private String apiKey;

    @Value("${dashscope.model:qwen-plus}")
    private String model;

    @Value("${dashscope.temperature:0.7}")
    private double temperature;

    @Value("${dashscope.top-p:0.8}")
    private double topP;

    @Value("${dashscope.max-tokens:2048}")
    private int maxTokens;

    /**
     * 初始化DashScope配置
     */
    @PostConstruct
    public void init() {
        // 如果提供了API密钥，则设置为系统属性
        if (apiKey != null && !apiKey.isEmpty()) {
            System.setProperty("dashscope.api.key", apiKey);
        }
    }

    // Getters
    public String getApiKey() {
        return apiKey;
    }

    public String getModel() {
        return model;
    }

    public double getTemperature() {
        return temperature;
    }

    public double getTopP() {
        return topP;
    }

    public int getMaxTokens() {
        return maxTokens;
    }
}